package com.cskaoyan.market.controller.Admin;

import com.cskaoyan.market.db.domain.MarketFootprint;
import com.cskaoyan.market.service.admin.MarketFootPrintService;
import com.cskaoyan.market.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServlet;
import java.io.IOException;
import java.util.List;

/**
 * @author: YaLiFeng
 * @description: TODO
 * @date: 2024/5/7 17:03
 */
@RestController
@RequestMapping("/admin/footprint")
public class AdminFootPrintController extends HttpServlet {
    @Autowired
    private MarketFootPrintService printService;
    @GetMapping("list")
    public Object list(String limit,String page,String order,String sort,String userId,String goodsId) throws IOException {

        Integer pageParam=null;
        Integer limitParam=null;
        try{
            pageParam=Integer.parseInt(page);
            limitParam=Integer.parseInt(limit);

        }catch(NumberFormatException e){
            Object object= ResponseUtil.badArgument();
            return ResponseUtil.fail();
        }

        List<MarketFootprint> marketFootprintList=printService.list(limitParam,pageParam,order,sort,userId,goodsId);
        return ResponseUtil.okList(marketFootprintList);



    }
}
